home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SGI Developer Toolbox 6.1
/
SGI Developer Toolbox 6.1 - Disc 4.iso
/
src
/
haeberli
/
tools
/
mousemon.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-08-01
|
2KB
|
107 lines
/*
* Copyright 1991, 1992, 1993, 1994, Silicon Graphics, Inc.
* All Rights Reserved.
*
* This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
* the contents of this file may not be disclosed to third parties, copied or
* duplicated in any form, in whole or in part, without the prior written
* permission of Silicon Graphics, Inc.
*
* RESTRICTED RIGHTS LEGEND:
* Use, duplication or disclosure by the Government is subject to restrictions
* as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
* and Computer Software clause at DFARS 252.227-7013, and/or in similar or
* successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
* rights reserved under the Copyright Laws of the United States.
*/
/*
* mousemon -
* Monitor the buttons of the mouse. This is useful for
* demos sometimes.
*
* Paul Haeberli - 1985
*
*/
#include "gl.h"
#include "device.h"
#include "port.h"
#define HWIDTH 0.6
int om1, om2, om3;
int m1, m2, m3;
main()
{
short val;
noborder();
keepaspect(2,3);
winopen("mousemon");
m1 = getbutton(MOUSE1);
m2 = getbutton(MOUSE2);
m3 = getbutton(MOUSE3);
qdevice(TIMER0);
qdevice(ESCKEY);
noise(TIMER0,5);
makeframe();
while (1) {
switch(qread(&val)) {
case TIMER0:
drawit();
break;
case REDRAW:
makeframe();
break;
case ESCKEY:
exit(0);
break;
}
}
}
drawit()
{
m1 = getbutton(MOUSE1);
m2 = getbutton(MOUSE2);
m3 = getbutton(MOUSE3);
if (m3!=om3) {
drawent(-2.1,m3);
om3 = m3;
}
if (m2!=om2) {
drawent(0.0,m2);
om2 = m2;
}
if (m1!=om1) {
drawent(2.1,m1);
om1 = m1;
}
}
drawent(x,val)
float x;
int val;
{
if (val) {
grey(0.0);
rectf(x-HWIDTH,0.6,x+HWIDTH,4.5);
} else {
grey(0.6);
rectf(x-HWIDTH,0.6,x+HWIDTH,4.5);
grey(0.0);
rect(x-HWIDTH,0.6,x+HWIDTH,4.5);
}
}
makeframe()
{
reshapeviewport();
ortho2(-4.0,4.0,-6.0,6.0);
grey(0.6);
rectf(-4.0,-6.0,4.0,6.0);
om1 = om2 = om3 = -1;
drawit();
}